package com.zjd.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zjd.dao.RouteDao;
import com.zjd.domain.Route;
import com.zjd.service.RouteService;
import com.zjd.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class RouteServiceImpl implements RouteService {

    @Override
    public PageInfo<Route> selectRouteByPage(int pageNum, int pageSize, int cid) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        RouteDao mapper = sqlSession.getMapper(RouteDao.class);
        PageHelper.startPage(pageNum,pageSize);
        List<Route> routes = mapper.selectRouteByCategoryId(cid);
        PageInfo<Route> pageInfo = new PageInfo<>(routes,10);
        MyBatisUtils.commitAndClose(sqlSession);
        return pageInfo;
    }
}
